using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;


public partial class Admin_EditLoaiSanPham : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            LoadData();
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"]);

            tbLoaiSanPhamEntities loaiSP = tbLoaiSanPhamBUS.GetByID(id);
            txt_MaLoai.Text = loaiSP.MaLoai.ToString();
            txt_TenLoai.Text = loaiSP.TenLoai.ToString();
        }
        catch
        {
            Response.Redirect("~/Admin/DanhSachLoai.aspx");
        }
    }
    protected void btn_Update_Click(object sender, EventArgs e)
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbLoaiSanPhamEntities loaiSP = tbLoaiSanPhamBUS.GetByID(id);
            loaiSP.TenLoai = txt_TenLoai.Text;
            tbLoaiSanPhamBUS.Update(loaiSP);
            Response.Redirect("~/Admin/DanhSachLoai.aspx");
        }
        catch
        {
            Response.Redirect("~/Admin/DanhSachLoai.aspx");
        }
    }
}
